/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.camachosanchez.bean;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ZULLY
 */
@Entity
@Table(name = "detalle_control_cambio_bateria")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DetalleControlCambioBateria.findAll", query = "SELECT d FROM DetalleControlCambioBateria d"),
    @NamedQuery(name = "DetalleControlCambioBateria.findById", query = "SELECT d FROM DetalleControlCambioBateria d WHERE d.id = :id"),
    @NamedQuery(name = "DetalleControlCambioBateria.findByTipo", query = "SELECT d FROM DetalleControlCambioBateria d WHERE d.tipo = :tipo"),
    @NamedQuery(name = "DetalleControlCambioBateria.findByPosicion", query = "SELECT d FROM DetalleControlCambioBateria d WHERE d.posicion = :posicion")})
public class DetalleControlCambioBateria implements Serializable, Comparable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "tipo")
    private short tipo;
    @Basic(optional = false)
    @Column(name = "posicion")
    private short posicion;
    @JoinColumn(name = "id_bateria", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Baterias idBateria;
    @JoinColumn(name = "id_control_cambio_neumatico", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private ControlCambioNeumatico idControlCambioNeumatico;

    public DetalleControlCambioBateria() {
    }

    public DetalleControlCambioBateria(Integer id) {
        this.id = id;
    }

    public DetalleControlCambioBateria(Integer id, short tipo, short posicion) {
        this.id = id;
        this.tipo = tipo;
        this.posicion = posicion;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public short getTipo() {
        return tipo;
    }

    public void setTipo(short tipo) {
        this.tipo = tipo;
    }

    public short getPosicion() {
        return posicion;
    }

    public void setPosicion(short posicion) {
        this.posicion = posicion;
    }

    public Baterias getIdBateria() {
        return idBateria;
    }

    public void setIdBateria(Baterias idBateria) {
        this.idBateria = idBateria;
    }

    public ControlCambioNeumatico getIdControlCambioNeumatico() {
        return idControlCambioNeumatico;
    }

    public void setIdControlCambioNeumatico(ControlCambioNeumatico idControlCambioNeumatico) {
        this.idControlCambioNeumatico = idControlCambioNeumatico;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleControlCambioBateria)) {
            return false;
        }
        DetalleControlCambioBateria other = (DetalleControlCambioBateria) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.camachosanchez.bean.DetalleControlCambioBateria[ id=" + id + " ]";
    }

    @Override
    public int compareTo(Object o) {
        DetalleControlCambioBateria detalle = (DetalleControlCambioBateria) o;
        int p1 = this.posicion;
        int p2 = detalle.getPosicion();
        int resultado = p1 < p2 ? -1 : (p1 == p2 ? 0 : 1);
        return resultado;
    }
    
}
